# -*- coding:utf-8 -*-
from __future__ import print_function
class ListNode:
    def __init__(self, x):
        self.val = x
        self.next = None

def printList(l):
    while l:
        print(l.val,end=' ')
        l = l.next
    print()
def creatList(array):
    if array == []:
        return None
    h = ListNode(array[0])
    t = h
    for i in array[1:]:
        t.next = ListNode(i)
        t = t.next
    return h

class Solution:
    # 返回从尾部到头部的列表值序列，例如[1,2,3]
    def printListFromTailToHead(self, listNode):
        # write code here
        ArrayList = []
        if ListNode != None:
            if ListNode.next != None:
                ArrayList = self.printListFromTailToHead(ListNode.next)
            ArrayList.append(ListNode.val)
        return ArrayList

a = []
l = creatList(a)
s = Solution().printListFromTailToHead
print(s(l))